import React from 'react';
import { createForm } from 'rc-form';
import { Button, InputItem, WingBlank, WhiteSpace,Toast,List} from 'antd-mobile';
import 'antd-mobile/dist/antd-mobile.css';
import { hashHistory} from 'react-router';
import './less/index.less';
import SelectItem from "../mall/selectItem";



const Item = List.Item;


let userMsg = {}
let fieldValue = {};
class ChooseAddr extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
            pickerValue: [],
            dpValue: null,
            listView:true,
            mobile:'',
            addr:'',
            address:'',
            consignee:''
        };
    }
    componentDidMount() {
        this.props.changeTitle('收获地址');
        this.setState({
            consignee:fieldValue.consignee === undefined ? '':fieldValue.consignee,
            mobile:fieldValue.mobile === undefined ? '': fieldValue.mobile,
            address:fieldValue.address === undefined ? '': fieldValue.address,
            addr:fieldValue.asyncValue === undefined ? '' : fieldValue.asyncValue,
        });
    }


    componentWillMount(){
        userMsg = this.props.location.state
    }

    //
    creatAddr = () => {
        hashHistory.push({
            pathname: '/car/addAddr',
        })
    }
    clickAddr = () =>{
        hashHistory.push(
            {
                pathname:'/car/addAddr',
                state:{
                    userMsg:userMsg,
                    fieldValue:fieldValue,
                }
            }
        )

    }
    changeItem = (e) => {
        this.setState({
            listView:!this.state.listView
        })

    }

    render() {
        return (


            <div className="my-list">
                <list>
                    <Item onClick={this.clickAddr} arrow="horizontal"  thumb="http://192.168.0.131:8091/ecommerce/20171205170318.png" align="middle" wrap>
                        <div className="Item-addr-name">
                            刘一
                        </div>
                        <div>
                             <span className="Item-addr-font">
                                福建省福州市鼓楼区东街口7号省电信大楼西区14楼中兴软创科技股份有限公司
                            </span>
                        </div>
                    </Item>
                </list>
                <div className="div-img" >
                </div>


                    <WhiteSpace/>
                <list>
                    <Item  arrow="horizontal"  align="middle" wrap>
                        <div style={{fontFamily:'PingFangSC-Semibold',fontSize:'32px',color:'#ff323a',textAlign:'left'}}>
                            {fieldValue.consignee}
                        </div>
                        <div>


                            <span className="Item-addr-font">
                                {fieldValue.address}
                            </span>
                        </div>
                    </Item>
                </list>
                <list>
                    <SelectItem/>
                    {this.state.listView ?
                        <Item onClick={this.changeItem} thumb="http://192.168.0.131:8091/ecommerce/20171205170318.png" arrow="horizontal"  align="middle" wrap>
                            <div style={{fontFamily:'PingFangSC-Semibold',fontSize:'32px',color:'#ff323a',textAlign:'left'}}>
                                刘一
                            </div>
                            <div>
                            <span className="Item-addr-font">
                                福建省福州市鼓楼区东街口7号省电信大楼西区14楼中兴软创科技股份有限公司
                            </span>
                            </div>
                        </Item>
                        :
                        <Item onClick={this.changeItem} arrow="horizontal"  align="middle" wrap>
                            <div style={{fontFamily:'PingFangSC-Semibold',fontSize:'32px',color:'#ff323a',textAlign:'left'}}>
                                刘一
                            </div>
                            <div>
                            <span className="Item-addr-font">
                                福建省福州市鼓楼区东街口7号省电信大楼西区14楼中兴软创科技股份有限公司
                            </span>
                            </div>
                        </Item>

                    }
                </list>
                    <WhiteSpace/>
                <div className="divX">
                    <WingBlank>
                        <WhiteSpace/>
                        <Button type="warning" size="large" onClick={this.creatAddr}>+ 新建地址</Button><WhiteSpace/>
                    </WingBlank>
                </div>
            </div>
        );
    }
}

export default createForm()(ChooseAddr);
